package blacknWhite.MarketSalesMonitor;

import android.media.AudioManager;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.Preference.OnPreferenceChangeListener;

public class PreferencesActivity extends PreferenceActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		addPreferencesFromResource(R.xml.preferences);
		this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
		
		Preference serviceEnabled = this.findPreference("serviceEnabled");
		serviceEnabled.setOnPreferenceChangeListener(new OnPreferenceChangeListener(){

			public boolean onPreferenceChange(Preference preference,
					Object newValue) {
				//CheckBoxPreference serviceEnabled = (CheckBoxPreference) preference;
				if ((Boolean)newValue)
					startService(MarketSalesMonitorService.GetIntent());
				else
					stopService(MarketSalesMonitorService.GetIntent());
				return true;
			}});
		

		Preference pref01 = this.findPreference("namespaceApp01");
		pref01.setSummary(getPreferenceManager().getSharedPreferences()
				.getString(pref01.getKey(), ""));

		Preference pref02 = this.findPreference("namespaceApp02");
		pref02.setSummary(getPreferenceManager().getSharedPreferences()
				.getString(pref02.getKey(), ""));
	
		Preference pref03 = this.findPreference("namespaceApp03");
		pref03.setSummary(getPreferenceManager().getSharedPreferences()
				.getString(pref03.getKey(), ""));

		Preference pref04 = this.findPreference("namespaceApp04");
		pref04.setSummary(getPreferenceManager().getSharedPreferences()
				.getString(pref04.getKey(), ""));

		Preference pref05 = this.findPreference("namespaceApp05");
		pref05.setSummary(getPreferenceManager().getSharedPreferences()
				.getString(pref05.getKey(), ""));

		Preference pref06 = this.findPreference("namespaceApp06");
		pref06.setSummary(getPreferenceManager().getSharedPreferences()
				.getString(pref06.getKey(), ""));

		Preference pref07 = this.findPreference("namespaceApp07");
		pref07.setSummary(getPreferenceManager().getSharedPreferences()
				.getString(pref07.getKey(), ""));

		Preference pref08 = this.findPreference("namespaceApp08");
		pref08.setSummary(getPreferenceManager().getSharedPreferences()
				.getString(pref08.getKey(), ""));

		Preference pref09 = this.findPreference("namespaceApp09");
		pref09.setSummary(getPreferenceManager().getSharedPreferences()
				.getString(pref09.getKey(), ""));

		Preference pref10 = this.findPreference("namespaceApp10");
		pref10.setSummary(getPreferenceManager().getSharedPreferences()
				.getString(pref10.getKey(), ""));
}
}